import http from '@/utils/request.js'

/***** 后台首页(Home) 模块 *******/
/* 首页轮播carousel */
//轮播：更新/增加分类 （id有则更新，无则增加）
export function  updateHomeCarousel(params) {
  let {id,img,title,product_id,seq} = params;
	return http.request({
		url: "/home/carousel",
		method: "post",
		data: {id,img,title,product_id,seq},
	});
}

//轮播：删除ById
export function  deleteHomeCarouselById(id) {
	return http.request({
		url: "/home/carousel",
		method: "delete",
		params: {id},
	});
}

//轮播： 查询列表(数据量不多，就不作分页处理了)
export function  getHomeCarouselList() {
	return http.request({
		url: "/home/carousel/list",
		method: "get",
	});
}

//轮播： 查询明细 ById
export function  getHomeCarouselDetailById(id) {
	return http.request({
		url: "/home/carousel/detail",
		method: "get",
    params:{id}
	});
}

/* 首页商品  product */
//商品：更新/增加分类 （id有则更新，无则增加）
export function  updateHomeProduct(params) {
  let {id,product_id,href,seq_recommended,seq_new_arrival,seq_top_sale} = params;
	return http.request({
		url: "/home/product",
		method: "post",
		data: {id,product_id,href,seq_recommended,seq_new_arrival,seq_top_sale},
	});
}

//商品：删除ById
export function  deleteHomeProductById(id) {
	return http.request({
		url: "/home/product",
		method: "delete",
		params: {id},
	});
}

//商品： 查询列表(数据量不多，就不作分页处理了)
export function  getHomeProductList() {
	return http.request({
		url: "/home/product/list",
		method: "get",
	});
}

//商品： 查询明细 ById
export function  getHomeProductDetailById(id) {
	return http.request({
		url: "/home/product/detail",
		method: "get",
    params:{id}
	});
}

//首页 Echars
// 查询统计某段日期订单商品分类销售数据 GET /home/echars/orderSumByFamily
// 参数：开始日期dtGgn、结束日期dtEnd（如:'20120101')
// 返回数据 :分类名family_name、数量count、金额amount
export function  getOrderSumByFamily(params) {
	return http.request({
		url: "/home/echars/orderSumByFamily",
		method: "get",
    params:params,
	});
}

// 查询统计年度各月份订单销售数据 GET /home/echars/orderSumByMonth
// 参数：年份year (如:2021)
// 返回数据 :月份month、数量count、金额amount
export function  getOrderSumByMonth(year) {
	return http.request({
		url: "/home/echars/orderSumByMonth",
		method: "get",
    params:{year},
	});
}
export function  getCollectionEchar(year) {
	return http.request({
		url: "/home/echars/collectionEchar",
		method: "get",
    params:{year},
	});
}
